NPC Engine Documentation

Release 8 -- 17. 12. 2000

 


Index

0. Disclaimer

1. What the NPC Engine does

2. Quick how-to to include the NPC Engine in your game

3. Path movement and subway movement

4. Advanced features

5. Functions

6. NPC_Engine properties

7. Entry points

8. Notes

9. Demo Story

10. Changes to the NPC Engine

 


0. Disclaimer

NPC Engine is a library extension for the Inform interactive fiction authoring system. It is provided "as is". The author takes no responsibility whatsoever for any malfunctioning of this code.

NPC Engine and this documentation are copyright (c) 1999, 2000 Volker Lanz. You may use these files in your own games freely. Please do not alter any of the files and publish or distribute these modified versions without the author's permission.

Parts of NPC_Wait.h were written by: Andrew Clover, L. Ross Raszewski and Nicholas Daley.

Original concept for subway movement by Infocom. Thanks to Mike Berlyn for help with this.

Contact the author via:

volker.lanz@gmx.net

Comments, bug reports, criticism, questions and suggestions are always welcome.

 


1. What the NPC Engine does

The NPC Engine initially was an integral part of my Inform version of Infocom's excellent game DEADLINE. After the game was mostly finished, I began isolating the NPC movement and description parts from the game and created this library extension out of these.

If you would like to have NPCs in your game that are wandering around in a more sophisticated manner than just moving them from one room to another each turn on a predefined path, and if you want the player to have the opportunity of following NPCs, this one is the right library extension for you.

Additionally, it offers these features:


2. Quick how-to to include the NPC Engine in your game

Assuming that you already have some skeleton of a game, follow these steps to integrate the NPC Engine into your story:


3. Path movement and subway movement

Beginning with release 6 of the NPC Engine, you can choose between two different types of movement calculation: Path movement or subway movement.

The default movement type is path movement. To use subway movement, you need to tell the NPC Engine that you intend to do so by setting the constant "SUBWAY_MOVE_TYPE" before including npc_engine.h.

Additionally, you of course have to set the "subway lines" the NPCs can "ride on" in your game. This is done using the npc_subway property in the rooms in your game:

   NPC_Room Front_Path "Front Path"
   with
   ...
   npc_subway   pink_line red_line,
   ...

Here, the pink and red subway lines run through the room Front_Path. Note that one line may only cross another line once and lines may not go in circles. There's a maximum number of lines and a maximum number of intersections; both of these can easily be changed. Have a look at the beginning of npc_engine.h for details on this.


4. Advanced features

Your window must not rely on NPC descriptions being printed! If no NPCs can be seen through it, nothing will be printed at all!

5. Functions


6. NPC_Engine properties

The following is a list of all the important properties each object of the NPC_Engine class has:


7. Entry points

These are the entry points the NPC Engine calls. Replace any of these functions in your own code to modify the behaviour of the engine.

Note: Some of these already do some stuff, so you should always copy the originals from the npc_engine.h file and modify these instead of writing completely new functions.

Always use cut and paste when replacing any of these entry points!

 


8. Notes

 


9. Demo Story

This release of the NPC Engine includes a small demo story in source and binary format to show the use of the engine. Note that, although this demo game features rooms from the game INTRUDER (which can be downloaded from ftp.gmd.de/if-archive/games/zcode/intruder.zip), it doesn't have any objects other than the rooms themselves (apart from a key to lock the only door that is there). Also, the NPCs aren't from INTRUDER.

If you want to see the NPC Engine really shine, you should have a look at the source code for the Inform version of DEADLINE. This source code is available from: ftp.gmd.de/if-archive/games/source/inform/Deadline.zip.


10. Changes to the NPC Engine

8.001217

The NPC Engine doesn't use the Inform Library's DEBUG constant anymore; define a "NPC_DEBUG" constant if you want to get debugging information.

A number of small bugs fixed (thanks to James Hayes for help with this).

If no path or next move was found, the NPC Engine will no longer print any error message; the functions will simply return false. The game itself has to deal with cases where it called the functions inside the Engine and may not rely on the Engine always returning a room or finding a path.

Follow-mode for NPCs added, so that NPCs can be set to follow the player.

GO TO verb added.

7.000606

Various little fixes and modifications to make the NPC Engine run a bit faster; games that use it are still nearly unplayable on a PDA, however (about 3 seconds per minute on an overclocked Palm IIIc).

Subway movement nearly completely rewritten; is now up to 40% faster than calculated paths.

The NPC_Engine object isn't a daemon anymore, but a floating object that is present in all rooms. This may seem a bit strange, but it ensures that the Inform Library always executes any daemons and timers before the NPCs are being moved and described.

No longer does the NPC Engine use the time_out and daemon properties of the Inform Library. You can now use timers and daemons in NPC Engine objects as you like.

Can now set the order in which NPCs are processed by manually setting their number and npc_next properties; must define NPC_MANUAL_NUMBERS before including npc_engine.h.

6.000111

No longer uses the NewRoom() entry point.

Only one type of following is supported from now on (formerly called PATH_follow_type).

New attribute: give an NPC the npc_hidden attribute and the NPC Engine will not print any descriptions of this NPC as long as it isn't in the same room as the player.

New property: npc_path_blocked() is called when an NPC can't go on because of a locked door in his way.

No modification of the player object required anymore.

Some support for pluralname objects (see notes)

NPCs are now in scope as long as they're visible to the player.

Subway movement type added.

Moving NPCs are no longer concealed; the NPC's describe() property has to deal itself with not printing a description then.

May now use routines or strings in (dir)_to properties, e.g.

   ...
   e_to "There is only a short blind corridor there.",
   ...

Doors may use "location" to check where they are (though this is bad style and therefore not recommended).

5.991122

New NPC_Msg() entry allows replacing standard message for "find" verb.

npc_before_action() is now only called if the NPC does indeed move.

NPC_Wait.h now comes with the NPC Engine to allow for complex waiting.

Bug fixed with stopping NPCs that suddenly weren't described anymore when they tried to leave.

Bug fixed in NPC_Move's call to PrintWindowVisible.

More small bug fixes.

This document created, replacing the old text file manual.

3.990531

Now works with Inform 6.21 and Library 6/9; complies to strict error checking rules

Minor modifications and enhancements to the manual

Demo game added

NPC Engine now uses TestScope() instead of comparing ScopeCeiling()s where possible.

1.990423 First public release